#!/usr/bin/env python
# -*- coding: utf-8 -*- 

#    pyogpo - ogpo calculator for 2009 year
#    Copyright (C) 2009 resurtm
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

from PyQt4 import QtCore, QtGui

class AboutWindow(QtGui.QWidget):
	def __init__(self):
		super(AboutWindow, self).__init__()
		
		self._prepareAppearance()
		
		self._prepareLayout()
		self._prepareWidgets()
		
	def _prepareAppearance(self):
		# block main window while viewing this one
		self.setWindowModality(QtCore.Qt.WindowModality(QtCore.Qt.ApplicationModal))
		
		# set window icon
		self.setWindowIcon(QtGui.QIcon('../icons/trayicon.png'))
		
		# set window title
		self.setWindowTitle(self.trUtf8('pyogpo — о программе'))
		
		# set window size
		self.setMaximumSize(400, 300)
		self.setMinimumSize(400, 300)
		self.resize(400, 300)
		
		# center window
		screen = QtGui.QDesktopWidget().screenGeometry()
		size = self.geometry()
		self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2)
		
	def _prepareLayout(self):
		self.layoutMain = QtGui.QGridLayout()
		self.setLayout(self.layoutMain)
		
	def _prepareWidgets(self):
		# load icon pixmap
		self.pixmapIcon = QtGui.QPixmap()
		self.pixmapIcon.load('../images/logo.png');
		# icon label
		self.labelIcon = QtGui.QLabel(self.trUtf8(''))
		self.layoutMain.addWidget(self.labelIcon, 0, 0, 2, 1)
		self.labelIcon.setPixmap(self.pixmapIcon)
		self.labelIcon.setAlignment(QtCore.Qt.Alignment(QtCore.Qt.AlignCenter))
		
		# title label
		self.labelTitle = QtGui.QLabel(self.trUtf8('<h2>Калькулятор ОГПО 2009<br />(Python версия)</h2>'))
		self.layoutMain.addWidget(self.labelTitle, 0, 1, 1, 1)
		# title2 label
		self.labelTitle2 = QtGui.QLabel(self.trUtf8('Для расчёта страховой премии по ОГПО'))
		self.layoutMain.addWidget(self.labelTitle2, 1, 1, 1, 1)
		
		# product version label
		self.labelProductVersion = QtGui.QLabel(self.trUtf8('<b>Версия продукта:</b>'))
		self.layoutMain.addWidget(self.labelProductVersion, 2, 0, 1, 1)
		# product version value label
		self.labelProductVersionValue = QtGui.QLabel(self.trUtf8('2009, 0.1 (под лицензией GNU GPL v3)'))
		self.layoutMain.addWidget(self.labelProductVersionValue, 2, 1, 1, 1)
		
		# product vendor label
		self.labelProductVendor = QtGui.QLabel(self.trUtf8('<b>Разработчик:</b>'))
		self.layoutMain.addWidget(self.labelProductVendor, 3, 0, 1, 1)
		# product vendor value label
		self.labelProductVendorValue = QtGui.QLabel(self.trUtf8('<u>resurtm@gmail.com</u>'))
		self.layoutMain.addWidget(self.labelProductVendorValue, 3, 1, 1, 1)
		
		# product idea label
		self.labelProductIdea = QtGui.QLabel(self.trUtf8('<b>Идея и<br />оригинальная версия:</b>'))
		self.layoutMain.addWidget(self.labelProductIdea, 4, 0, 1, 1)
		# product idea value label
		self.labelProductIdeaValue = QtGui.QLabel(self.trUtf8('магазин онлайн страхования'))
		self.layoutMain.addWidget(self.labelProductIdeaValue, 4, 1, 1, 1)
		
		# product homepage label
		self.labelHomepage = QtGui.QLabel(self.trUtf8('<b>Домашняя страница:</b>'))
		self.layoutMain.addWidget(self.labelHomepage, 5, 0, 1, 1)
		# product homepage value label
		self.labelProductHomepageValue = QtGui.QLabel(self.trUtf8('<u>http://webpolis.kz/</u>'))
		self.layoutMain.addWidget(self.labelProductHomepageValue, 5, 1, 1, 1)
		
		# close button
		self.buttonClose = QtGui.QPushButton(self.trUtf8('Закрыть'))
		self.layoutMain.addWidget(self.buttonClose, 6, 1, 1, 1)
		self.buttonClose.clicked.connect(self._buttonClose_clicked)
		
	def _buttonClose_clicked(self):
		self.close()
		
if __name__ == '__main__':
	pass